From: Paul Donald Date: Tue, 21 Oct 2025 23:22:04 +0000 (+0200) Subject: luci-mod-status: routes: prevent null error if the commands don't resolve X-Git-Url: http://git.openwrt.org/%22https:/collectd.org//%22%24PHP_SELF/%22https:/collectd.org/%22%24PHP_SELF?a=commitdiff_plain;h=3aefa564733ecd10aa80409ed84deeeb1c1078c7;p=project%2Fluci.git luci-mod-status: routes: prevent null error if the commands don't resolve Closes #8026 Signed-off-by: Paul Donald --- diff --git a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/routes.js b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/routes.js index 6b249a0fbe..7c7668110a 100644 --- a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/routes.js +++ b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/routes.js @@ -39,12 +39,12 @@ return view.extend({ load() { return Promise.all([ callNetworkInterfaceDump(), - L.resolveDefault(fs.exec('/sbin/ip', [ '-4', 'neigh', 'show' ]), {}), - L.resolveDefault(fs.exec('/sbin/ip', [ '-4', 'route', 'show', 'table', 'all' ]), {}), - L.resolveDefault(fs.exec('/sbin/ip', [ '-4', 'rule', 'show' ]), {}), - L.resolveDefault(fs.exec('/sbin/ip', [ '-6', 'neigh', 'show' ]), {}), - L.resolveDefault(fs.exec('/sbin/ip', [ '-6', 'route', 'show', 'table', 'all' ]), {}), - L.resolveDefault(fs.exec('/sbin/ip', [ '-6', 'rule', 'show' ]), {}), + L.resolveDefault(fs.exec('/sbin/ip', [ '-4', 'neigh', 'show' ]), { stdout: '' }), + L.resolveDefault(fs.exec('/sbin/ip', [ '-4', 'route', 'show', 'table', 'all' ]), { stdout: '' }), + L.resolveDefault(fs.exec('/sbin/ip', [ '-4', 'rule', 'show' ]), { stdout: '' }), + L.resolveDefault(fs.exec('/sbin/ip', [ '-6', 'neigh', 'show' ]), { stdout: '' }), + L.resolveDefault(fs.exec('/sbin/ip', [ '-6', 'route', 'show', 'table', 'all' ]), { stdout: '' }), + L.resolveDefault(fs.exec('/sbin/ip', [ '-6', 'rule', 'show' ]), { stdout: '' }), L.hasSystemFeature('ufpd') ? callUfpList() : null ]); }, @@ -81,6 +81,7 @@ return view.extend({ }, parseNeighbs(nbs, macs, networks, v6) { + if (!nbs) return []; const res = []; for (const line of nbs.trim().split(/\n/)) { @@ -115,6 +116,7 @@ return view.extend({ }, parseRoutes(routes, networks, v6) { + if (!routes) return []; const res = []; for (const line of routes.trim().split(/\n/)) { @@ -145,7 +147,7 @@ return view.extend({ return res; }, - parseRules: rules => rules.trim().split('\n').map(l => { + parseRules: rules => rules?.trim()?.split('\n')?.map(l => { const [, prio=null, rule=null] = l.match(/^(\d+):\s+(.+)$/) || []; return [prio, rule]; }),